-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Major refactor, API changes, new tests #8
Conversation
bcb6bb9
to
587feef
Compare
I'm temporarily skipping the disconnected graph test for the Fiedler vector / value computation. I think fixing this should be relatively straightforward - just add a custom TRACEMIN solver to better handle this. A naive solution would be to add some regularization to the anchored Laplacian that gets built inside the solver, e.g. as If There are interesting potential performance considerations here, I think. It might be better to attempt to solve for the Fiedler value and vector without this regularization, then catch the internal linear system solver exception and fall back to the regularized version? I'll leave this for a future PR, though. The remaining TODOs as far as I can tell are:
|
Summary
This PR introduces a major project restructure, some API changes, and new tests.
At a high level, the new project structure looks something like this:
I won't go into detail about the content that is consistent with what is on
main
, but in terms of the new files, we have:frankwolfe.py
and implementation of linear program oracles for a variety of compact, convex constraint sets inconstraints.py
.utils.py
andcholesky_utils.py
files. These are now split up into separate utility filesconversions.py
for NetworkX < > MAC format conversions,graphs.py
for Laplacian constructors and general graph manipulation utils,rounding.py
for rounding to the feasible sets implemented inconstraints.py
, andcholesky.py
for Suitesparse Cholesky support. I also movedfiedler.py
containing our custom hooks into the NetworkX TRACEMIN-Fiedler implementation here, but I might move these to a separatefiedler
directory along with the specialized Cholesky utilities specific to Fiedler value computation.Bugs squashed
frankwolfe.py
the relative duality gap convergence criterion sets a threshold of the form(dual_upper_bound - f(x)) / f(x) < relative_duality_gap_threshold
. This will fail iff(x)
happens to be zero, and will "false positive" iff(x)
is negative. We fix this by moving thef(x)
in the denominator to the right-hand side and taking the absolute value. So we now compute(upper - f(x)) < relative_duality_gap_threshold * f(x)
. This is more robust numerically, but of course if f(x) is indeed zero, it will never trigger. I think this is OK for now. The fix would likely be to add some absolute duality gap threshold, but this seems pretty hard to specify, since we do not know the "scale" of f(x).conversions.py
, there were a variety of subtly bugs converting between NetworkX graphs and the MAC edge list format. These were mostly because the code was "overfit" to the specific case where the NetworkX graphs we were interested in were all unweighted (or had weights uniformly equal to one). This is fixed now.Testing
New tests added to
tests/...
including:optimization
libraries, running Frank-Wolfe on some simple constrained concave maximization problems (e.g. quadratic objective). We now explicitly test cases likef(x) \approx 0
which would have caused a "divide by zero" error before (see above)utils
libraries. We now test for connected / disconnected graphs in our Fiedler value computations. The latter test (disconnected graph) is currently failing. We need to fix this to improve support for features onkjd/no-fixed-graph
, but we actually have a test now! We also test our routines for converting between NetworkX and MAC, which actually had some subtle bugs (see above).